<template>
  <!-- 近期新书 -->
  <section class="recent-book">
    <h2>
      <span>近期新书</span>
      <div>
        <img src="@/assets/images/首页/播放键@2x(1).png" alt="" />
        <span>播放全部</span>
      </div>
    </h2>
    <ul>
      <router-link
        class="li"
        v-for="value of recentBookList"
        :key="value.title"
        :to="/detail/ + value.pdsid"
      >
        <img :src="value.imgUrl" alt="" />
        <p>{{ value.title }}</p>
        <p>{{ value.view }}</p>
      </router-link>
    </ul>
  </section>
</template>

<script>
import { onMounted, computed } from "vue";
import { useStore } from "vuex";
export default {
  setup() {
    const store = useStore();
    const getRecentBook = () => store.dispatch("getRecentBook");
    onMounted(() => getRecentBook());
    // 近期新书列表
    const recentBookList = computed(
      () => store.state.recommend.getRecentBook.result
    );
    return {
      recentBookList,
      getRecentBook,
    };
  },
};
</script>

<style lang="less" scoped>
// 近期新书
.recent-book {
  margin-bottom: 25px;
  padding: 0 12px;
  h2 {
    margin-bottom: 12px;
    color: #000000;
    font-size: 18px;
    font-family: PingFang SC;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    div {
      display: flex;
      align-items: center;
      img {
        width: 16px;
        height: 16px;
        margin-right: 5px;
      }
      span {
        color: #464447;
        font-size: 13px;
      }
    }
  }
  ul {
    display: flex;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    .li {
      margin-right: 15px;
      display: flex;
      flex-direction: column;
      align-items: center;
      img {
        width: 89px;
        height: 114px;
        margin-bottom: 9px;
      }
      p {
        font-family: PingFang SC;
        font-weight: bold;
        margin: 0;
        &:first-of-type {
          margin-bottom: 5px;
          color: #3d3d3d;
          font-size: 14px;
        }
        &:last-of-type {
          color: #c9a35c;
          font-size: 12px;
        }
      }
    }
  }
}
</style>
